package com.aaa.service.impl;

import com.aaa.dao.FcartMapper;
import com.aaa.entity.Fcart;
import com.aaa.service.FcartServiceDao;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class FcartServiceImpl extends ServiceImpl<FcartMapper,Fcart> implements FcartServiceDao {
    @Resource
    FcartMapper mapper;
    @Resource
    FcartServiceDao dao;
    @Override
    public List<Fcart> select(Integer pageNum, Integer pageSize, Fcart fcart) {
        return mapper.select(pageNum,pageSize,fcart);
    }

    @Override
    public List<Map> selectall(Integer fuser) {
        return mapper.selectall(fuser);//根据登录用户来查数据
    }
    public boolean upadd(Fcart fcart){
        Date date=new Date();
        SimpleDateFormat sdft=new SimpleDateFormat("yyyy-MM-dd");
        String time=sdft.format(date);
        fcart.setTime(time);
        boolean upad= dao.saveOrUpdate(fcart);
        return upad;//添加或者修改
    }
    public Integer del(Integer id){
        int del=mapper.deleteById(id);
        return del;
    }//删除
}
